package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.CarType;
import com.zygh.interactiveplatform.module.service.CarTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 车辆类型 前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/car-type")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_CARTYPE})
public class CarTypeController {
    @Resource
    private CarTypeService carTypeService;

    @ApiOperation(value = "新增号牌种类", notes = "新增号牌种类")
    @PostMapping("addCarTypee")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_CARTYPE, content = "新增号牌种类")
    public ResponseDTO addCarTypee(@RequestBody @Valid CarType carType) {
        return carTypeService.addCarType(carType);
    }
    @ApiOperation(value = "修改号牌种类", notes = "修改号牌种类")
    @PostMapping("updateCarType")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_CARTYPE, content = "修改号牌种类")
    public ResponseDTO updateCarType(@RequestBody @Valid CarType carType) {
        return carTypeService.updateCarType(carType);
    }
    @ApiOperation(value = "删除号牌种类", notes = "删除号牌种类")
    @PostMapping("deleteCarType")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_CARTYPE, content = "删除号牌种类")
    public ResponseDTO deleteCarType(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return carTypeService.deleteCarType(new_id);
    }
    @ApiOperation(value = "查询所有号牌种类", notes = "查询所有号牌种类")
    @GetMapping("findCarTypeAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_CARTYPE, content = "查询所有号牌种类")
    public ResponseDTO findCarTypeAll(Integer current, Integer size) {
        return carTypeService.findCarTypeAll(current,size);
    }
}
